
import 'dart:ui';

import 'package:flutter/services.dart';

class Common {

  static double screenWidth = 0;
  static double screenHeight = 0;
  static double statusBarHeight = 0;
  static double bottomBarHeight = 0;

  static const myplatform = MethodChannel("methodChannel");

  /// 配置一些需要基本信息
  static _initScreenSize() {
    double physicalWidth = window.physicalSize.width;
    double physicalHeight = window.physicalSize.height;
    double dpr = window.devicePixelRatio;

    screenWidth = physicalWidth / dpr;
    screenHeight = physicalHeight / dpr;
    _fixScreenSize();
    statusBarHeight = window.padding.top / dpr;
    bottomBarHeight = window.padding.bottom / dpr;
  }

  static _fixScreenSize() {
    double tempW = screenWidth;
    double tempH = screenHeight;
    if (screenWidth > screenHeight) {
      screenWidth = tempH;
      screenHeight = tempW;
    } else {
      screenWidth = tempW;
      screenHeight = tempH;
    }
  }

// 是否为release版
  static bool get isRelease => const bool.fromEnvironment("dart.vm.product");

  //初始化全局信息，会在APP启动时执行
  static Future init() async {
  }

  static initBaseData() {
    _initScreenSize();
  }
}